import logging
from redis import StrictRedis


class Config(object):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information17"
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    REDIS_NUM = 7
    SECRET_KEY = "DSFDSGFDDSADASDSDFDFfdsdf"
#   1.session设置数据库类型
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT,
                              db=REDIS_NUM)
#   2.session加密处理
    SESSION_USE_SIHNER = True
#   3.session不设置过期时长
    SESSION_PERMANENT = False
#   4.session的过期时长
    PERMANENT_SESSION_LIFETIME = 86400 * 2



class DevelopmentConfig(Config):
    # 开发模式下
    DEBUG = True
    LOG_LEVEL = logging.DEBUG



class ProductionConfig(Config):
    # 开发模式下
    DEBUG = False
    LOG_LEVEL = logging.WARNING


config_dict = {
    "development":DevelopmentConfig,
    "production":ProductionConfig
}


